#ifndef __WAD_HPP__
#define __WAD_HPP__

#include <cstdlib>
#include <cstdint>
#include <fstream>
#include <string>

#include "section.hpp"
#include "content.hpp"

using namespace std;

class wad_t
{
	protected:
	bool opened;
	
	uint32_t wadtype;
	
	section_t header;
	section_t cert;
	section_t tik;
	section_t tmd;
	section_t contents;
	section_t footer;
	
	ifstream wadstream;
	uint8_t titlekey[16];
	
	content_t* content;
	uint16_t contentcount;
	
	void decrypt_title_key(uint8_t* title_key);
	
	public:
	wad_t();
	wad_t(string wadfile);
	~wad_t();
	void init();
	bool open(string wadfile);
	void close();
	bool is_open();
	void print_header();
	bool unpack(string destpath);
};

#endif //__WAD_HPP__
